pomelo = require 'pomelo'
routeUtil = require './app/util/routeUtil'
globalChannel = require 'pomelo-globalchannel-plugin'


app = pomelo.createApp()

app.set 'name', 'chatofpomelo'

# app configure
app.configure 'production|development', ()->
	# route configures
	app.route 'chat', routeUtil.chat

	app.use globalChannel, {globalChannel: {
		host: '127.0.0.1',
		port: 6379,
		db: '0'
	}}

	# filter configures
	app.filter pomelo.timeout()

# start app

app.start()

process.on 'uncaughtException', (err)->
	console.error ' Caught exception: ' + err.stack
